from seleniumbase import SB

with SB(uc=True, test=True, locale="en", guest=True) as sb:
    url = "https://www.pokemon.com/us"
    sb.activate_cdp_mode(url)
    sb.sleep(1.5)
    sb.click_if_visible("button#onetrust-accept-btn-handler")
    sb.sleep(1.2)
    sb.click("a span.icon_pokeball")
    sb.sleep(2.5)
    sb.click('b:contains("Show Advanced Search")')
    sb.sleep(2.5)
    sb.click('span[data-type="type"][data-value="electric"]')
    sb.sleep(0.7)
    sb.scroll_into_view("a#advSearch")
    sb.sleep(0.7)
    sb.click("a#advSearch")
    sb.sleep(1.2)
    sb.click('img[src*="img/pokedex/detail/025.png"]')
    sb.assert_text("Pikachu", 'div[class*="title"]')
    sb.assert_element('img[alt="Pikachu"]')
    sb.scroll_into_view("div.pokemon-ability-info")
    sb.sleep(1.2)
    sb.cdp.flash('div[class*="title"]')
    sb.cdp.flash('img[alt="Pikachu"]')
    sb.cdp.flash("div.pokemon-ability-info")
    name = sb.get_text("label.styled-select")
    info = sb.get_text("div.version-descriptions p.active")
    print("*** %s: ***\n* %s" % (name, info))
    sb.sleep(2)
    sb.cdp.highlight_overlay("div.pokemon-ability-info")
    sb.sleep(2)
    sb.open("https://events.pokemon.com/EventLocator/")
    sb.sleep(2)
    sb.click('span:contains("Championship")')
    sb.sleep(2)
    events = sb.select_all("div.event-info__title")
    print("*** Pokémon Championship Events: ***")
    for event in events:
        print("* " + event.text)
    sb.sleep(2)
